package pages;


import java.util.List;

import org.openqa.selenium.By;

import bsh.This;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import utils.BaseAction;

public class HomePage {
	private AndroidDriver<AndroidElement> driver;
	private BaseAction action;
	
	public HomePage(AndroidDriver<AndroidElement> driver) {
		this.driver = driver;
		this.action = new BaseAction(driver);
	}
	
	public AndroidElement homesearch() {
		return driver.findElementByXPath("//android.widget.Button[@content-desc=\"搜索\"]");
	}
	
	public AndroidElement search_setcontent() {
		return driver.findElementByName("搜索");
	}
	public AndroidElement send_LYN() {
		return driver.findElementByXPath("android.view.View[@content-desc=\"L LYN 5月13日 0j\"]");
	}
	
	public AndroidElement send_SYSTEM() {
		return driver.findElementByXPath("//android.view.View[@content-desc=\"系统 5月5日 LYN: /\"]");
	}
	
	public AndroidElement send_lyn() {
		return driver.findElementByName("发送消息");
	}
	public AndroidElement send_system() {
		return driver.findElementByName("发送消息");
	}
	
	
	
	
	public int count_note() {
		AndroidElement list_view = driver.findElementById("android:id/list");
		List<MobileElement> items = list_view.findElementsById("android:id/text1");
		
		int count = items.size();
		return count;
	}
	
	
	
	
	
	public void test_search(String sear_content) throws InterruptedException {
		action.click(this.homesearch());
		action.setValue(this.search_setcontent(), sear_content);
	}
	

	public void test_send_lyn(String message) throws InterruptedException {
		action.click(this.send_LYN());
		action.setValue(this.send_lyn(), message);
		
	}
	public void test_send_system(String message) throws InterruptedException {
		action.click(this.send_SYSTEM());
		action.setValue(this.send_system(), message);
		
	}

//	public void note_update(String content) throws InterruptedException {
//		action.click(this.items0());
//		Thread.sleep(2000);
//		action.click(this.more());
//		action.click(this.editTitle_Notes());
//		action.setValue(edit(), content);
//		Thread.sleep(1000);
//		action.click(this.ok());
//		action.click(this.Save_Notes());
//	}
//	
//	public void note_paste() throws InterruptedException {
//		action.longPress(this.items0());
//		Thread.sleep(1000);
//		action.click(this.copy_Notes());
//		Thread.sleep(1000);
//		action.click(this.more());
//		Thread.sleep(1000);
//		action.click(this.paste_Notes());
//		Thread.sleep(1000);
//		action.click(this.Save_Notes());
//		Thread.sleep(1000);
//	}
	
	

}
